package utilidad;

import java.io.IOException;
import java.net.InetAddress;

import javax.swing.JFrame;
import javax.swing.JPanel;

import cliente.VentanaIP;

public class Ping {
	private JFrame vIP;
	public Ping()
	{
		//hacer una ventana con Cargando en grande
		vIP = new JFrame();
		JPanel cargando= new JPanel();

		vIP.setVisible(true);
	}

	public  boolean realizarPing(String ip) { 

		InetAddress ping; 
		boolean funciona=false;
		try { 

			ping = InetAddress.getByName(ip);

			if(ping.isReachable(2000))
			{ 

				System.out.println(ip+" - responde!"); 
				funciona=true;

			}else { 

				System.out.println(ip+" - no responde!"); 
				funciona=false;
			}
		} catch (IOException ex) { System.out.println(ex); }

		return funciona;
	} 

}
